[slug].vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <script lang='ts' setup>
  2. import { Api } from '@/api/model/url'
  3. import { useCommonStore } from '@/stores/modules/common'
  4. import { Condition } from '@/enums/const-enums'
  5. const config = useRuntimeConfig()
  6. const { apiBaseSiteUrl } = config.public
  7. const route = useRoute()
  8. const detail = ref<any>({})
  9. const tabValue = ref('blog')
  10. const isHasCatalogue = ref(true)
  11. const options = ref([
  12. {
  13. label: 'Read Blog',
  14. value: 'blog',
  15. },
  16. {
  17. label: 'Preview Catalog',
  18. value: 'catalog',
  19. },
  20. ])
  21. const slug = route.params.slug
  22. const { data, pending, error, refresh } = await useAsyncData(
  23. 'blog-detail',
  24. () =>
  25. $fetch(`${apiBaseSiteUrl}${Api.BlogDetail}`, { params: { slug } }),
  26. )
  27. const seoData = data.value?.result
  28. // 把createTime和updateTime转换为ISO格式
  29. if (seoData?.createTime)
  30. seoData.createTime = new Date(seoData.createTime).toISOString()
  31. if (seoData?.updateTime)
  32. seoData.updateTime = new Date(seoData.updateTime).toISOString()
  33. if (!seoData?.relatedCatalogue)
  34. isHasCatalogue.value = false
  35. detail.value = seoData
  36. useHead({
  37. title: detail.value?.metaTitle,
  38. meta: [
  39. {
  40. name: 'description',
  41. content: detail.value?.metaDescribe,
  42. },
  43. {
  44. property: 'og:title',
  45. content: detail.value?.metaTitle,
  46. },
  47. {
  48. property: 'og:description',
  49. content: detail.value?.metaDescribe,
  50. },
  51. {
  52. property: 'og:image',
  53. content: detail.value?.thumbnailUrl,
  54. },
  55. {
  56. property: 'og:url',
  57. content: `${apiBaseSiteUrl}/blog/${slug}`,
  58. },
  59. {
  60. property: 'og:type',
  61. content: 'website',
  62. },
  63. {
  64. property: 'twitter:title',
  65. content: detail.value?.metaTitle,
  66. },
  67. {
  68. property: 'twitter:description',
  69. content: detail.value?.metaDescribe,
  70. },
  71. {
  72. property: 'twitter:site',
  73. content: `${apiBaseSiteUrl}/blog/${slug}`,
  74. },
  75. {
  76. property: 'twitter:image',
  77. content: detail.value?.thumbnailUrl,
  78. },
  79. {
  80. property: 'twitter:card',
  81. content: 'summary_large_image',
  82. },
  83. ],
  84. script: [
  85. // JSON-LD
  86. {
  87. type: 'application/ld+json',
  88. children: JSON.stringify({
  89. datePublished: detail.value?.createTime,
  90. dateModified: detail.value?.updateTime,
  91. }),
  92. },
  93. ],
  94. link: [
  95. {
  96. rel: 'canonical',
  97. href: `${apiBaseSiteUrl}/blog/${slug}`,
  98. },
  99. ],
  100. })
  101. const { openLoginAndDownloadModal } = useLoginAndDownLoadModal()
  102. async function clickLoginAndDownload(item: any) {
  103. try {
  104. const commonStore = useCommonStore()
  105. commonStore.setDownloadCatalog(item)
  106. const { status } = await openLoginAndDownloadModal()
  107. if (status)
  108. location.reload()
  109. }
  110. catch (error) {
  111. console.log(error)
  112. }
  113. }
  114. </script>
  115. <template>
  116. <div class="blog-detail">
  117. <div class="bg-#F3F4FB ">
  118. <div class="pt-175px pb-110px w-1200-auto flex px-60px">
  119. <img :src="detail?.thumbnailUrl" :alt="detail?.thumbnailAlt" srcset="" class="w-410px h-256px b-rd-10px object-cover mr-40px">
  120. <div class="flex-1 text-left">
  121. <div class="b-rd-400px left-10px text-center w-138px h-32px lh-32px bg-#fff/50 backdrop-blur-20px b-1px b-solid b-#fff/60 text-#9B6CFF text-14px mb-20px">
  122. {{ detail.category_dictText }}
  123. </div>
  124. <h1
  125. class="!mb-20px fw-800 text-40px ls-2 text-#333 line-clamp-2 lh-50px custom-title-font"
  126. >
  127. {{ detail.contentTitle }}
  128. </h1>
  129. <div class="text-16px text-#999 lh-24px">
  130. {{ detail.contentSubhead }}
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. <div class="w-1200-auto flex pt-30px">
  136. <div class="w-840px mr-60px">
  137. <div v-if="isHasCatalogue">
  138. <el-segmented v-model="tabValue" :options="options">
  139. <template #default="scope">
  140. <div>
  141. <div>{{ scope.item.label }}</div>
  142. </div>
  143. </template>
  144. </el-segmented>
  145. </div>
  146. <div v-show="tabValue === 'blog'" class="mt-30px content-detail custom-html" v-html="detail.content" />
  147. <div v-show="tabValue === 'catalog'" class="mt-30px">
  148. <iframe
  149. :src="`${detail?.relatedCatalogue?.viewPdf}#view=FitH&toolbar=0&scrollbar=0&navpanes=0`"
  150. allowfullscreen
  151. width="100%"
  152. height="1200px"
  153. style="border: none"
  154. >
  155. 您的浏览器不支持iframe,请使用现代浏览器查看PDF。
  156. </iframe>
  157. </div>
  158. </div>
  159. <div class="flex-1">
  160. <div v-if="isHasCatalogue" class="pos-relative mb-40px">
  161. <img :src="detail?.relatedCatalogue?.coverImg" :alt="detail?.relatedCatalogue?.coverAlt" srcset="" class="w-375px h-240px b-rd-10px object-cover">
  162. <h4
  163. class="!mb-15px !mt-30px fw-800 text-24px text-#333 line-clamp-2"
  164. >
  165. {{ detail?.relatedCatalogue?.title }}
  166. </h4>
  167. <div class="text-14px text-#999 lh-22px line-clamp-2 mb-20px">
  168. {{ detail?.relatedCatalogue?.subhead }}
  169. </div>
  170. <el-button class="!bg-#9B6CFF !text-#fff !b-#9B6CFF !b-rd-380px text-14px fw-bold !h-32px px-20px" @click="clickLoginAndDownload(detail?.relatedCatalogue)">
  171. {{ detail?.relatedCatalogue?.downloadCondition === Condition.REQUEST ? 'Request' : 'Download' }} Catalog
  172. </el-button>
  173. </div>
  174. <div class="px-40px pt-34px bg-#E7EAFF b-rd-10px text-center custom-main">
  175. <div class="text-#333 fw-500">
  176. Sign in for exclusive trending product catalogs!
  177. </div>
  178. <el-button class="mt-20px !bg-#fff !text-#9B6CFF !w-160px !h-40px !b-0px !b-rd-200px" round>
  179. <nuxt-link :to="{ name: 'contact' }">
  180. Sign In
  181. </nuxt-link>
  182. </el-button>
  183. </div>
  184. </div>
  185. </div>
  186. <common-block-blog class="!pb-0" />
  187. <AppFooter />
  188. </div>
  189. </template>
  190. <style lang='less' scoped>
  191. .el-segmented {
  192. --el-segmented-item-selected-color: #fff;
  193. --el-segmented-item-selected-bg-color: #9B6CFF;
  194. --el-border-radius-base: 16px;
  195. --el-segmented-bg-color: #F9FAFB;
  196. --el-segmented-color: #333;
  197. width: 100%;
  198. height: 68px;
  199. line-height: 68px;
  200. border-radius: 300px!important;
  201. overflow: hidden;
  202. padding: 0;
  203. ::v-deep .el-segmented__group {
  204. .el-segmented__item-selected,.el-segmented__item{
  205. border-radius: 300px!important;
  206. overflow: hidden;
  207. .el-segmented__item-label{
  208. font-size: 18px;
  209. }
  210. }
  211. }
  212. }
  213. .blog-detail {
  214. ::v-deep(.content-detail) {
  215. font-family: sans-serif;
  216. h2 {
  217. font-size: 1.5em;
  218. font-family: "CustomTitleFont";
  219. margin-top: 1em !important;
  220. margin-bottom: 1em !important;
  221. font-weight: bold;
  222. }
  223. h3 {
  224. display: block;
  225. font-size: 1.17em;
  226. margin-block-start: 1em;
  227. margin-block-end: 1em;
  228. margin-inline-start: 0px;
  229. margin-inline-end: 0px;
  230. margin-bottom: 1em !important;
  231. font-weight: bold;
  232. unicode-bidi: isolate;
  233. font-family: "CustomTitleFont";
  234. }
  235. p {
  236. display: block;
  237. margin-block-start: 1em;
  238. margin-block-end: 1em;
  239. margin-inline-start: 0px;
  240. margin-inline-end: 0px;
  241. unicode-bidi: isolate;
  242. }
  243. ul {
  244. display: block;
  245. list-style-type: disc;
  246. margin-block-start: 1em;
  247. margin-block-end: 1em;
  248. margin-inline-start: 0px;
  249. margin-inline-end: 0px;
  250. padding-inline-start: 40px;
  251. unicode-bidi: isolate;
  252. li {
  253. display: list-item;
  254. text-align: -webkit-match-parent;
  255. unicode-bidi: isolate;
  256. }
  257. }
  258. ol {
  259. list-style-type: decimal;
  260. display: block;
  261. list-style-type: decimal;
  262. margin-block-start: 1em;
  263. margin-block-end: 1em;
  264. margin-inline-start: 0px;
  265. margin-inline-end: 0px;
  266. padding-inline-start: 40px;
  267. unicode-bidi: isolate;
  268. }
  269. }
  270. }
  271. .custom-main{
  272. background: url('~/assets/images/swiper_bg.png') no-repeat center center;
  273. background-size: cover;
  274. width: 300px;
  275. height: 190px;
  276. }
  277. </style>